import { createBrowserRouter } from "react-router-dom";

import Layout from "@/pages/Layout";
import Login from "../pages/Login";
// import Home from "@/pages/Layout/Home";
// import Article from "@/pages/Layout/Article";
// import Publish from "@/pages/Layout/Publish";

// 打包优化-路由懒加载  lazy函数  Suspense组件
import { lazy, Suspense } from "react";
const Home = lazy(() => import("@/pages/Layout/Home"));
const Article = lazy(() => import("@/pages/Layout/Article"));
const Publish = lazy(() => import("@/pages/Layout/Publish"));

const router = createBrowserRouter([
  {
    path: "/",
    element: <Layout />,
    children: [
      {
        // path: "home",
        index: true,
        element: (
          <Suspense fallback={"加载中..."}>
            <Home />
          </Suspense>
        ),
      },
      {
        path: "article",
        element: (
          <Suspense fallback={"加载中..."}>
            <Article />
          </Suspense>
        ),
      },
      {
        path: "publish",
        element: (
          <Suspense fallback={"加载中..."}>
            {" "}
            <Publish />
          </Suspense>
        ),
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
]);
export default router;
